<?php
/**
 * Created by IntelliJ IDEA.
 * User: Administrator
 * Date: 2019/11/26
 * Time: 20:59
 */

namespace app\admin\controller;

use think\Session;
use think\Controller;
use app\admin\model\Login1 as Login1Model;

class Login1 extends Controller
{
    public function index()
    {
        return $this->fetch();
    }

    public function login($username, $password)
    {
        $user = Login1Model::get(['Aname' => $username]);
        if (empty($user)){
            $this->error('用户不存在');
        }
        if ($user['Apassword'] == $password) {
//            $_SESSION['username'] = $username;
            session('username', $username);
            $this->success('登录成功','food/index');
        } else {
            $this->error('登录失败');
        }
    }


    public function logout()
    {
        Session::clear();
        $this->success('退出成功','login1/index');
    }
}
